package top.suven.base.http.admin.sec.dao;

import org.apache.ibatis.annotations.*;
import top.suven.base.core.mybatis.crud.CommonCrudMapper;
import top.suven.base.http.admin.sec.model.Menu;

import java.util.List;

/**
 * @Title: MenuService.java
 * @Description: 菜单的数据交互类
 * @author lixiangling
 * @date   2018/08/13 16:58:49
 * @version V1.0.0
 * ----------------------------------------------------------------------------
 *  modifyer    modifyTime                 comment
 *
 * ----------------------------------------------------------------------------
 *
 */
public interface MenuDao extends CommonCrudMapper<Menu> {
    @Select("<script> " +
    "select * from  sec_menu where status='1' and enable_status='1' and menu_code in " +
    "<foreach item='item' index='index' collection='idList' open='(' separator=',' close=')'> " +
    "#{item} " +
    "</foreach> " +
    "</script>")
    @Results(
        id="menu",
        value = {
            @Result(column = "menu_code" , property = "menuCode"),
			@Result(column = "menu_name" , property = "menuName"),
			@Result(column = "parent_menu_code" , property = "parentMenuCode"),
			@Result(column = "menu_uri" , property = "menuUri"),
			@Result(column = "menu_desc" , property = "menuDesc"),
			@Result(column = "menu_type" , property = "menuType"),
			@Result(column = "status" , property = "status"),
			@Result(column = "reorder" , property = "reorder"),
			@Result(column = "enable_status" , property = "enableStatus")
        }
    )
    List<Menu> getMenuByList(@Param("idList") List<String> idList);
    /**
     * @Title: 删除菜单信息
     * @Description:id @{Link Long[]}
     * @param
     * @return
     * @throw
     * @author lixiangling
     * @date 2018/08/13 16:58:49
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     */
    @Update("<script> " +
            "UPDATE sec_menu set status='0'"+
            "WHERE menu_code IN " +
            "<foreach item='item' index='index' collection='idList' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach> " +
            "</script>")
    void del(@Param("idList") List<String> idList);
    /**
     * @Title: 禁用菜单信息
     * @Description:id @{Link Long}
     * @param
     * @return
     * @throw
     * @author lixiangling
     * @date 2018/08/13 16:58:49
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     */
     @Update("<script> " +
             "UPDATE sec_menu  " +
             "SET menu_code = #{enableStatus}  " +
             "WHERE user_id IN " +
             "<foreach item='item' index='index' collection='idList' open='(' separator=',' close=')'> " +
             "#{item} " +
             "</foreach> " +
             "</script>")
     void updateEnableStatus(@Param("enableStatus") String enableStatus, @Param("idList") List<String> idList);
}